package com.andy.buyu.server.dto;

import com.andy.buyu.server.game.GameUser;

import io.netty.buffer.ByteBuf;

/**
 * 用户登录
 * @author cuiwm
 */
public class UserMessage extends BaseMessage{
	
    private GameUser user;
    
    public UserMessage(GameUser user) {
    	this.user = user;
	}

	@Override
	public void writeBody(ByteBuf buf) {
		if(user == null){
			writeString(buf,"0");
		}else{
			writeString(buf,user.getId().toString());
			writeString(buf,user.getUserName());
			buf.writeLong(user.getGameInfo().getCoin());
			writeString(buf,user.getNickName());
			buf.writeInt(user.getUser().getIcon());
		}
	}


}